/*
 * @Date: 2023-02-21 18:42:11
 * @LastEditors: Zireael 1193875164@qq.com
 * @LastEditTime: 2023-03-08 20:08:23
 * @FilePath: \A19\backend\src\api\Create\ApiCreateHomework.ts
 */
/*
 * @Date: 2023-02-21 18:42:11
 * @LastEditors: Zireael 1193875164@qq.com
 * @LastEditTime: 2023-02-21 19:14:04
 * @FilePath: \A19\backend\src\api\Create\ApiCreateHomework.ts
 */
import { ApiCall } from "tsrpc";
import {
  ReqCreateHomework,
  ResCreateHomework,
} from "../../shared/protocols/Create/PtlCreateHomework";
import { homework } from "../../shared/types/homework";
import { Global } from "../../Global";

export default async function (
  call: ApiCall<ReqCreateHomework, ResCreateHomework>
) {
  // TODO
  const teacher = call.currentUser;
  const { course, startTime, endTime, name, questions,status } = call.req;

  const homework = {
    course,
    startTime,
    endTime,
    name,
    questions,
    status
  };

  await Global.collection("homework").insertOne(homework);
  call.succ({});
}
